package vo;

import model.Goods;
import model.Seckill;
import service.GoodsService;
import service.impl.GoodsServiceImpl;
import utils.DateUtil;

import java.io.Serializable;

/**
 * @Description:
 * @Author one world
 * @Date 2020/9/25 0025 21:59
 */
public class SeckillVo implements Serializable {
    private String id;
    private String goods_id;
    private String goods_name;
    private String start;
    private String end;
    private String stotal;
    private String num;
    private String price;
    private String state;
    private String url;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getGoods_name() {
        return goods_name;
    }

    public void setGoods_name(String goods_name) {
        this.goods_name = goods_name;
    }

    public SeckillVo() {
    }

    public SeckillVo(Seckill seckill){
        this.id=String.valueOf(seckill.getId());
        this.goods_id=String.valueOf(seckill.getGoods().getId());
        this.start=String.valueOf(DateUtil.toString(seckill.getStart_time(),"yyyy-MM-dd HH:mm:ss"));
        this.end=String.valueOf(DateUtil.toString(seckill.getEnd_time(),"yyyy-MM-dd HH:mm:ss"));
        this.stotal=String.valueOf(seckill.getStotal());
        this.num=String.valueOf(seckill.getNum());
        this.price=String.valueOf(seckill.getSprice());
        this.state=String.valueOf(seckill.getState());
        GoodsService service = new GoodsServiceImpl();
        Goods goods = service.findById(seckill.getGoods().getId());
        this.goods_name= String.valueOf(goods.getName());
        this.url = String.valueOf(goods.getPicture());
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getGoods_id() {
        return goods_id;
    }

    public void setGoods_id(String goods_id) {
        this.goods_id = goods_id;
    }

    public String getStart() {
        return start;
    }

    public void setStart(String start) {
        this.start = start;
    }

    public String getEnd() {
        return end;
    }

    public void setEnd(String end) {
        this.end = end;
    }

    public String getStotal() {
        return stotal;
    }

    public void setStotal(String stotal) {
        this.stotal = stotal;
    }

    public String getNum() {
        return num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    @Override
    public String toString() {
        return "SeckillVo{" +
                "id='" + id + '\'' +
                ", goods_id='" + goods_id + '\'' +
                ", goods_name='" + goods_name + '\'' +
                ", start='" + start + '\'' +
                ", end='" + end + '\'' +
                ", stotal='" + stotal + '\'' +
                ", num='" + num + '\'' +
                ", price='" + price + '\'' +
                ", state='" + state + '\'' +
                ", url='" + url + '\'' +
                '}';
    }
}
